package com.zhuozhou.jdyc.main.menu.fragment;

import android.os.Bundle;
import android.view.Gravity;
import android.view.View;

import androidx.core.content.ContextCompat;
import androidx.fragment.app.Fragment;

import com.zhuozhou.jdyc.R;
import com.zhuozhou.jdyc.base.BaseRecyclerViewAdapter;
import com.zhuozhou.jdyc.base.BaseRecyclerViewFragment;
import com.zhuozhou.jdyc.base.BaseRecyclerViewModel;
import com.zhuozhou.jdyc.databinding.SmartrecyclerviewBinding;
import com.zhuozhou.jdyc.main.menu.adapter.JokeAdapter;
import com.zhuozhou.jdyc.main.menu.bean.JokeBean;
import com.zhuozhou.jdyc.wight.dialog.MenuDialog;

/**
 * Create by CherishTang on 2020/3/20 0020
 * describe:
 */
public class JokeFragment extends BaseRecyclerViewFragment<BaseRecyclerViewModel,SmartrecyclerviewBinding, JokeBean> {
    @Override
    protected BaseRecyclerViewAdapter<JokeBean, ?> getRecyclerAdapter() {
        return new JokeAdapter(getActivity());
    }

    @Override
    protected void initData(Bundle bundle) {
        super.initData(bundle);
        requestData();
    }

    @Override
    protected void requestData() {
        super.requestData();
//        mViewModel.getJoke(mCurrentPage);
    }

    public static Fragment instantiate(Bundle bundle) {
        Fragment fragment = new JokeFragment();
        fragment.setArguments(bundle);
        return fragment;
    }

    @Override
    public void onItemClick(View view, int position) {
        super.onItemClick(view, position);
        if (position == 0) {
            new MenuDialog(getContext())
                    .setData("复制", "删除")
                    .setDialogGravity(Gravity.CENTER)
                    .setNegativeTextColor(ContextCompat.getColor(getActivity(), R.color.themeColor))
                    .setShowCancelButton(true)
                    .builder()
                    .show();
        } else if (position == 1) {
            new MenuDialog(getContext())
                    .setData("复制", "删除")
                    .setDialogGravity(Gravity.BOTTOM)
                    .setShowCancelButton(true)
                    .builder()
                    .show();
        } else if (position == 2) {
            new MenuDialog(getContext())
                    .setData("复制", "删除")
                    .setDialogGravity(Gravity.CENTER)
                    .setShowCancelButton(false)
                    .builder()
                    .show();
        } else if (position == 3) {
            new MenuDialog(getContext())
                    .setData("复制", "删除")
                    .setDialogGravity(Gravity.BOTTOM)
                    .setShowCancelButton(false)
                    .builder()
                    .show();
        }
    }
}
